export function getObjValue(obj, key) {
  let res = obj
  let keys = key.split('.')
  for (let item of keys) {
    if (res[item]) {
      res = res[item]
    } else {
      return key
    }
  }
  return res
}

export const findGroup = function (name, groupArray) {
  for (var index = 0; index < groupArray.length; index++) {
    if (groupArray[index].name === name) {
      return groupArray[index];
    }
  }
  return null;
};

// Helper method: add a new group to an array of groups
export const addGroup = function (groupName, groupArray) {
  var group = {
    name: groupName,
    items: [],
    paletteItems: [],
    groups: [],
    visible: true
  };
  groupArray.push(group);
  return group;
};